package com.weiyan.blog.controller;

import com.weiyan.blog.response.Result;
import com.weiyan.blog.response.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author misterWei
 * @create 2020年01月17号:17点18分
 * @mailbox mynameisweiyan@gmail.com
 */
@CrossOrigin
@RequestMapping("/sys")
@RestController
@Api("首页文章接口")
@RefreshScope
public class IndexController {
    @Value("${test}")
    private String test;

    @ApiOperation(value = "查询文章",notes = "分页查询")
    @RequestMapping(value = "index",method = RequestMethod.GET)
    @PreAuthorize("hasAuthority('sys')")
    public Result index(){
        return new Result(ResultCode.SUCCESS, SecurityContextHolder.getContext().getAuthentication().getPrincipal());
    }


}
